import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { UploadTypeEnum } from '/@/components/Form/src/jeecg/components/JUpload';
import { rules } from '/@/utils/helper/validator';
import { render, formattingMin } from '/@/utils/common/renderUtils';
//列表数据
export const columns : BasicColumn[] = [
	/* {
	  title: 'trash',
	  align:"center",
	  dataIndex: 'trash'
	 }, */
	{
		title: '创建时间',
		align: "center",
		dataIndex: 'createtime',
		customRender: ({ text }) => {
			return formattingMin(text)
		}
	},
	{
		title: '级别类型',
		align: "center",
		dataIndex: 'leveltype_dictText'
	},
	{
		title: '携程几钻',
		align: "center",
		dataIndex: 'extinfor',
		customRender:({text})=>{
			let o=JSON.parse(text)
			return o.diamondGrade || '待设置'
		}
	},
	{
		title: '总共几晚',
		align: "center",
		dataIndex: 'daynum'
	},
	{
		title: '房价总金额',
		align: "center",
		dataIndex: 'price'
	},

	{
		title: '图片',
		align: "center",
		dataIndex: 'images',
		customRender: render.renderImage,
	},
];
//查询数据
export const searchFormSchema : FormSchema[] = [
	{
		label: "级别类型",
		field: 'leveltype',
		component: 'JDictSelectTag',
		componentProps: {
			dictCode: "leveltype"
		},
		//colProps: {span: 6},
	},
];
//表单数据
export const formSchema : FormSchema[] = [
	/*  {
		label: 'trash',
		field: 'trash',
		component: 'Input',
		dynamicRules: ({model,schema}) => {
			  return [
					 { required: true, message: '请输入trash!'},
			  ];
		 },
	  }, */
	{
		label: '级别类型',
		field: 'leveltype',
		component: 'JDictSelectTag',
		componentProps: {
			dictCode: "leveltype"
		},
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请选择级别类型' },
			];
		},
	},
	{
		label: '携程几钻标准',
		field: 'diamondGrade',
		component: 'JDictSelectTag',
		componentProps: {
			options:[
				{label:'1钻',value:"1"},
				{label:'2钻',value:"2"},
				{label:'3钻',value:"3"},
				{label:'4钻',value:"4"},
				{label:'5钻',value:"5"}
			]
		},
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请选择级别类型' },
			];
		},
	},
	{
		label: '住几晚',
		field: 'daynum',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入住几晚!' },
				{ pattern: /^-?\d+$/, message: '请输入整数!' },
			];
		},
	},
	{
		label: '房价总金额',
		field: 'price',
		component: 'InputNumber',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入房价总金额!' },
				{ pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!' },
			];
		},
	},
	{
		label: '图片',
		field: 'images',
		component: 'JUpload',
		helpMessage: '最多上传20张图片',
		componentProps: {
			fileType: UploadTypeEnum.image,
			maxCount: 20,
		},
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请上传图片!' },
			];
		},
	},
	{
		label: '房间详情',
		field: 'msg',
		component: 'JEditor',
		componentProps: {
		},
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入详细介绍!' },
			];
		},
	},
	// TODO 主键隐藏字段，目前写死为ID
	{
		label: '',
		field: 'id',
		component: 'Input',
		show: false
	},
];



/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData) : FormSchema[] {
	// 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
	return formSchema;
}